package com.coinworld.exception;


import com.coinworld.response.ResponseCode;
import com.coinworld.utils.ParamMessageUtils;

public class BusinessException extends RuntimeException {

    private ResponseCode.IResponseCode code;

    public BusinessException(String message) {
        super(message);
        this.code = ResponseCode.Common.FAILURE;
    }

    public BusinessException(ResponseCode.IResponseCode code) {
        super(code.getMsg());
        this.code = code;
    }

    public BusinessException(String message, Object... arguments) {
        super(ParamMessageUtils.format(message, arguments));
    }

    public BusinessException(ResponseCode.IResponseCode code, String message) {
        super(message);
        this.code = code;
    }

    public BusinessException(ResponseCode.IResponseCode code, String message, Object... arguments) {
        super(ParamMessageUtils.format(message, arguments));
        this.code = code;
    }

    public ResponseCode.IResponseCode getCode() {
        return code;
    }

    public void setCode(ResponseCode.IResponseCode code) {
        this.code = code;
    }

    @Override
    public Throwable fillInStackTrace() {
        return this;
    }
}
